#include "loader/TokenLine.h"
#include "util/StringUtil.h"

using namespace std;

TokenLine::TokenLine(std::string line, char delimiter) {
	tokens = StringUtil::split(line, delimiter);
}

unsigned int TokenLine::size() const {
	return tokens.size();
}

std::string TokenLine::getString(unsigned int position) const{
	return tokens[position];
}

int TokenLine::getInt(unsigned int position) const {
	return atoi(tokens[position].c_str());
}

std::string TokenLine::getChars(unsigned int position) const{
	return tokens[position].c_str();
}

float TokenLine::getFloat(unsigned int position) const{
	return (float)atof(tokens[position].c_str());
}

double TokenLine::getDouble(unsigned int position) const{
	return atof(tokens[position].c_str());
}

long TokenLine::getLong(unsigned int position) const {
	return atol(tokens[position].c_str());
}

bool TokenLine::isEmpty(unsigned int position) const {
	if (position >= tokens.size())
		return true;
	else
		return tokens[position].size() == 0;
}

TokenLine::~TokenLine() {
}
